package com.xbs.controller.hitchhiking;
import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
/**
 * 修改顺风车的ajax
 */
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.controller.enterprise.DateJsonValueProcessor;
import com.xbs.entity.EmployeeEntity;
import com.xbs.service.hitchhiking.EmpAdminService;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;
@WebServlet("/backstage/xgcarajax")
public class XgCarAjaxServlet extends BaseServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		EmpAdminService emp = new EmpAdminService();
		
		/**
		 * 根据车牌号来修改信息
		 */
		List<EmployeeEntity> xgemp= emp.xgEmpByid(req.getParameter("xgsfz"));
		JsonConfig jsonConfig = new JsonConfig();   
		jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);   
		jsonConfig.registerJsonBeanProcessor(java.sql.Date.class, new DateJsonValueProcessor());  
		jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    
		//JSONArray jsonArray = JSONArray.fromObject(xgemp.getIst(),jsonConfig);
		JSONObject obj =null;
		if(xgemp.size()>0){
			obj =JSONObject.fromObject(xgemp.get(0),jsonConfig); 
		}
		resp.getWriter().print(obj);
	}
}
